package com.powernode.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.powernode.domain.Area;
import com.powernode.domain.IndexImg;
import com.powernode.service.AreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/area")
@Api(tags = "地址管理")
public class AreaController {


    @Autowired
    private AreaService areaService;


    //地址可以不用分页
    @GetMapping("/list")
    @ApiOperation(value = "地址列表")
    @PreAuthorize("hasAuthority('admin:area:page')")
    public ResponseEntity<List<Area>> areaList(Area area) {
        List<Area> list = areaService.areaList(area);
        return ResponseEntity.ok(list);
    }

    @GetMapping("/listByPid")
    @ApiOperation(value = "地址列表")
    public ResponseEntity<List<Area>> pickAddrAreaList(Long pid) {
        List<Area> list =  areaService.pickAddrAreaList(pid);
        return ResponseEntity.ok(list);
    }



}
